package com.cc.openeye.find.item.cardAuther

import androidx.compose.runtime.Composable
import com.cc.openeye.backgroundColor
import com.cc.openeye.find.entity.find.Item
import com.cc.openeye.height
import com.cc.openeye.padding
import com.tencent.kuikly.compose.coil3.rememberAsyncImagePainter
import com.tencent.kuikly.compose.foundation.Image
import com.tencent.kuikly.compose.foundation.layout.Column
import com.tencent.kuikly.compose.foundation.layout.fillMaxWidth
import com.tencent.kuikly.compose.foundation.shape.RoundedCornerShape
import com.tencent.kuikly.compose.material3.Text
import com.tencent.kuikly.compose.ui.Modifier
import com.tencent.kuikly.compose.ui.draw.clip
import com.tencent.kuikly.compose.ui.graphics.Color
import com.tencent.kuikly.compose.ui.layout.ContentScale
import com.tencent.kuikly.compose.ui.platform.LocalActivity
import com.tencent.kuikly.compose.ui.text.font.FontWeight
import com.tencent.kuikly.compose.ui.unit.dp
import com.tencent.kuikly.compose.ui.unit.sp
import com.tencent.kuikly.core.pager.Pager

@Composable
fun CardAuther(item: Item, index: Int) {
    println("====>CardAuther:${item.data?.title}, ${index}")

    val localPager = LocalActivity.current.getPager() as Pager

    Column(
        modifier = Modifier.clip(RoundedCornerShape(topStart = 8.dp, topEnd = 8.dp))
            .padding(start = 15f, end = 15f)
    ) {
        println("====>icon:${item.data?.icon}")
        Image(
            rememberAsyncImagePainter(
                item.data?.icon,
                onSuccess = { success ->
                    println("====>success:${item.data?.title}, ${index}")
                },
            ),
            contentDescription = "img",
            contentScale = ContentScale.Crop,
            modifier = Modifier.fillMaxWidth().height(localPager.pageData.pageViewWidth / 2)
                .backgroundColor(Color(0xfff5f5f5)),
        )

        Text(
            item.data?.title ?: "",
            fontSize = 16.sp,
            fontWeight = FontWeight.W600,
            modifier = Modifier.padding(top = 8f)
        )

        Text(
            item.data?.description ?: "",
            fontSize = 14.sp,
            modifier = Modifier.padding(top = 8f, bottom = 15f)
        )
    }
}